#include <stateMachine.h>
enum MY_CHECK_STATE_ENUM
{
    MY_CHECK_STATE_0 = 0,
    MY_CHECK_STATE_1,
    MY_CHECK_STATE_2,
    MY_CHECK_STATE_3,
    MY_CHECK_STATE_4,
    MY_CHECK_STATE_5,
    MY_CHECK_STATE_6,
};
int stateMachineCheckInit(struct statMcBaseStruct *thisState)
{
    logdebug("init %d", thisState->stateId);
    switch (thisState->stateId)
    {
    case MY_CHECK_STATE_0:
    {
        statMcMngTranst(thisState->stateManager, MY_CHECK_STATE_1);
        break;
    }
    default:
        break;
    }
    return 0;
}
int stateMachineCheckRun(struct statMcBaseStruct *thisState)
{
    logdebug("run %d", thisState->stateId);
    switch (thisState->stateId)
    {
    case MY_CHECK_STATE_1:
    {
        statMcMngTranst(thisState->stateManager, MY_CHECK_STATE_2);
        break;
    }
    case MY_CHECK_STATE_3:
    {
        statMcMngTranst(thisState->stateManager, MY_CHECK_STATE_0);
        statMcMngQuit(thisState->stateManager);
        break;
    }
    default:
        break;
    }
    return 0;
}
int stateMachineCheckQuit(struct statMcBaseStruct *thisState)
{
    logdebug("quit %d", thisState->stateId);
    switch (thisState->stateId)
    {
    default:
        break;
    }
    return 0;
}

int stateMachineCheck2Init(struct statMcBaseStruct *thisState)
{
    logdebug("init %d", thisState->stateId);
    return 0;
}
int stateMachineCheck2Run(struct statMcBaseStruct *thisState)
{
    logdebug("run %d", thisState->stateId);
    statMcMngTranst(thisState->stateManager, MY_CHECK_STATE_3);
    return 0;
}
int stateMachineCheck2Quit(struct statMcBaseStruct *thisState)
{
    logdebug("quit %d", thisState->stateId);
    statMcMngTranst(thisState->stateManager, MY_CHECK_STATE_0);
    return 0;
}

struct statMcMngStruct myCheckStateMnger;

struct statMcBaseStruct myCheckStates[] = {
    statMcBaseDefine(stateMachineCheckInit, stateMachineCheckRun, stateMachineCheckQuit, MY_CHECK_STATE_0, &myCheckStateMnger),
    statMcBaseDefine(stateMachineCheckInit, stateMachineCheckRun, NULL, MY_CHECK_STATE_1, &myCheckStateMnger),
    statMcBaseDefine(NULL, stateMachineCheck2Run, stateMachineCheck2Quit, MY_CHECK_STATE_2, &myCheckStateMnger),
    statMcBaseDefine(stateMachineCheckInit, stateMachineCheckRun, stateMachineCheckQuit, MY_CHECK_STATE_3, &myCheckStateMnger),
};

int main()
{
    int tmpflag = 0;
    statMcMngInit(&myCheckStateMnger, NULL, myCheckStates, ARRAY_LEN(myCheckStates), MY_CHECK_STATE_0);
    while (1)
    {
        tmpflag = statMcMngRun(&myCheckStateMnger);
        if(tmpflag < 0)
        {
            break;
        }
        usleep(1000 * 1000);
    }
}
